﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MMDemo
{
    public partial class LinearSearchForm : Form
    {
        public LinearSearchForm()
        {
            InitializeComponent();
        }

        private void Okbtn_Click(object sender, EventArgs e)
        {
            string tempStr = InputStrtext.Text;
            if (tempStr=="")
            {
                MessageBox.Show("请输入数据!");
                return;
            }
            if (radioButton2.Checked == true)
            {
                PublicDataClass.IsSearchForIndex = true;
                try
                {
                    if (Convert.ToUInt32(tempStr) <= 0)
                    {
                        MessageBox.Show("按位查找必须为正整数!");
                        return;
                    }
                    PublicDataClass.IsInit = true;
                }
                catch
                {
                    MessageBox.Show("按位查找必须为正整数!");
                    return;
                }
            }
            if (radioButton1.Checked)
            {
                PublicDataClass.IsSearchForIndex = false;
            }
            PublicDataClass.SearchData = tempStr;
            this.Close();
        }
        protected override void WndProc(ref   Message m)
        {
            const int WM_SYSCOMMAND = 0x0112;
            const int SC_CLOSE = 0xF060;
            if (m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE)
            {
                PublicDataClass.IsInit = false;
                this.Close();
                return;
            }
            base.WndProc(ref m);
        }
    }
}
